<?php require_once ADMINVIEWPATH.'admin_header.php'; ?>
<?php require_once ADMINVIEWPATH.'admin_menu.php'; ?>
<!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li>
                            <i class="fa fa-home"></i>
                            <a href="#">首页</a>
                        </li>
                        <li>
                            <a href="#">新闻管理</a>
                        </li>
                        <li class="active"> 新闻列表 </li>
                    </ul>
                </div>
                <!-- Page Body -->
                <div class="page-body">
                    <div class="row">
                        <div class="col-xs-12 col-md-12">
                            <div class="tab-content tabs-flat no-padding">
                                <div id="visits" class="tab-pane active animated fadeInUp">
                                    <div class="row">
                                        <div class="col-lg-12 chart-container">
                                            <div id="dashboard-chart-visits" class="chart chart-lg no-margin">
                                                <div class="widget-body">
                                                     <div class="table-toolbar">
                                                            <a href="/luckydog/news/textures?type=<?=$type?>" id="editabledatatable_new"   class=" btn btn-default">添加新闻</a>
                                                        </div>
                                                        <table class="table table-striped table-bordered table-hover" id="simpledatatable">
                                                            <thead>
                                                                <tr>
                                                                    <th>ID</th>
                                                                    <th>标题</th>
                                                                    <th>内容</th>
                                                                    <th>添加时间</th>
                                                                    <th>添加人</th>
                                                                    <th>状态</th>
                                                                    <th>操作</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody>
                                                            <tr>
                                                                <?php if(!empty($newsList)):?>
                                                                    <?php foreach($newsList as $key=> $row):?>
                                                                        <tr class="gradeX ">
                                                                            <td class="center"><?php echo $row['newsID']?></td>
                                                                            <td class="center"><?php echo $row['title']?></td>
                                                                            <td class="center reivew_video" data-content = "<?php echo  cutstr(strip_tags($row['content']),30,"……")?>"><div><?php echo  cutstr(strip_tags($row['content']),30,"……")?></div></td>
                                                                            <td class="center"><?php echo  date("Y-m-d h:i",$row['addtime'])?></td>
                                                                            <td class="center"><?php echo  $row['username']?></td>
                                                                             <td class="center">
                                                                                <?php if($row['onlinestatus'] == 1){?>
                                                                                    上架
                                                                                <?php }elseif($row['onlinestatus'] == 0){?>
                                                                                    下架
                                                                                <?php }?>
                                                                            </td>
                                                                            <td class="center " data_id = "<?php echo $row['newsID'];?>">
                                                                                <a href="/luckydog/news/textures?type=<?=$type?>&id=<?php echo $row['newsID'];?>" >编辑</a>&nbsp;|&nbsp;
                                                                                <a  href="javascript:;" class="J_onlinestatus" type="onlinestatus" onlinestatus="<?php echo $row['onlinestatus'];?>" >
                                                                            <?php if($row['onlinestatus'] == 1){?>
                                                                                下架
                                                                            <?php }elseif($row['onlinestatus'] == 0){?>
                                                                                上架
                                                                            <?php }?>
                                                                        </a>&nbsp;|
                                                                                <a href="javascript:;" class="J_del">删除</a>
                                                                            </td>
                                                                        </tr>
                                                                    <?php endforeach;?>
                                                                <?php endif;?>
                                                            </tr>
                                                            </tbody>
                                                        </table>
                                                    </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>

       
        <!-- /Page Content -->
<script src="<?php echo STATICURL; ?>js/jquery-2.0.3.min.js"></script>
<script src="<?php echo STATICURL; ?>layer/layer.js"></script>
<?php require_once ADMINVIEWPATH.'admin_footer.php'; ?>
<script src="<?=STATICURL; ?>layer/layer.js"></script>
<script>
   

    $('.tab_active').on('click',function(){
        var type = $(this).attr('data-type');
        location = '/luckydog/news/index?type='+type;
    })
    $(document).ready(function() {
        $(".J_del").click(function() {
            var id = $(this).parent().attr("data_id");
            if (confirm("您确定要删除吗？")) {
                $.post("/luckydog/news/delNews", {"id":id}, function(res) {
                    if (res) {
                        window.location.reload();
                    }else{
                        alert("删除失败");
                    }
                });
            }
        });

        $(".J_onlinestatus").click("click",function(){
            var newsID = $(this).parent().attr("data_id");
            var onlinestatus = $(this).attr("onlinestatus");
            var des = "确定上架吗？";
            if(onlinestatus == 1){
                onlinestatus = 0;
                des = "确定要下架吗？";
            }else{
                onlinestatus = 1;
            }
            if(confirm(des)){
                $.post("/luckydog/news/editStatus",{"newsID":newsID,"onlinestatus":onlinestatus,"type":"onlinestatus"},function(res){
                    if(res){
                         window.location.reload();
                    }else{
                        alert("失败");
                    }
                });
            }
        });
    });

</script>


